package cn.wolfcode.car.service.impl;

import cn.wolfcode.car.domain.Department;
import cn.wolfcode.car.mapper.DepartmentMapper;
import cn.wolfcode.car.qo.DepartmentQueryObject;
import cn.wolfcode.car.service.IDepartmentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class DepartmentServiceImpl implements IDepartmentService {

    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public int delete(Long id) {
        return departmentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int save(Department record) {
        return departmentMapper.insert(record);
    }

    @Override
    public Department get(Long id) {
        return departmentMapper.selectByPrimaryKey(id);
    }

    @Override
    public PageInfo<Department> list(DepartmentQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Department> list = departmentMapper.selectForPage(qo);
        return new PageInfo<>(list);
    }

    @Override
    public List<Department> listAll() {
        return departmentMapper.selectAll();
    }

    @Override
    public int update(Department record) {
        return departmentMapper.updateByPrimaryKey(record);
    }


}
